package com.gw.smscheck.controller.sys;

import com.github.pagehelper.PageInfo;
import com.gw.smscheck.entity.sys.LoginUser;
import com.gw.smscheck.service.sys.LoginUserService;
import com.gw.smscheck.util.ResultConversion;
import com.gw.smscheck.util.ResultObj;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 系统用户控制层
 * @Author: JunYaoWang
 * @Data: Created in 15:44 2018/11/14
 */
@Controller
@RequestMapping("/loginUserController")
@Api(description="【系统用户接口】")
public class LoginUserController {
    @Autowired
    private LoginUserService loginUserService;



    /**
     * 分页查询
     * @return
     */
    @ApiOperation(value="分页查询", notes="分页查询")
    @RequestMapping(value="/pageSelect",method={RequestMethod.POST})
    @ResponseBody
    public String pageSelect(LoginUser user){
        PageInfo<LoginUser> pageInfo = loginUserService.pageSelect(user);
        return ResultConversion.ToEasyUIDataGrid(pageInfo).toJSONString();
    }

    /**
     * 添加
     * @param user
     * @return
     */
    @ApiOperation(value="添加", notes="添加")
    @RequestMapping(value="/add",method={RequestMethod.POST})
    @ResponseBody
    public ResultObj add(LoginUser user){
        return loginUserService.add(user);
    }

    /**
     * 修改
     * @param user
     * @return
     */
    @ApiOperation(value="修改", notes="修改")
    @RequestMapping(value="/update",method={RequestMethod.POST})
    @ResponseBody
    public String update(LoginUser user){
        return ResultObj.successResultObj(loginUserService.update(user));
    }

    /**
     * 根据id查询
     * @param user
     * @return
     */
    @ApiOperation(value="根据id查询", notes="根据id查询")
    @RequestMapping(value="/findById",method={RequestMethod.POST})
    @ResponseBody
    public String findById(LoginUser user){
        return ResultObj.successResultObj(loginUserService.findById(user));
    }

    /**
     * 根据id删除
     * @param user
     * @return
     */
    @ApiOperation(value="根据id删除", notes="根据id删除")
    @RequestMapping(value="/delete",method={RequestMethod.POST})
    @ResponseBody
    public String delete(LoginUser user){
        return ResultObj.successResultObj(loginUserService.delete(user));
    }

}
